﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using Deixei.Domain;

namespace Deixei.Web.Controllers
{
    public abstract class DeixeiController : Controller
    {

        private DeixeiWebContext deixeiWebContext;

        public DeixeiWebContext DeixeiWebContext
        {
            get
            {
                if (this.deixeiWebContext == null)
                {
                    this.deixeiWebContext = base.Request.RequestContext.DeixeiWebContext();
                }
                return this.deixeiWebContext;
            }
        }

        public IUnitOfWork UnitOfWork
        {
            get;
            set;
        }

        public DeixeiController()
        {
            UnitOfWork = new UnitOfWork();
        }

        protected override void Dispose(bool disposing)
        {
            UnitOfWork.Dispose();
            base.Dispose(disposing);
        }
    }
}
